<?php
/*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/

if ($_GET["port"] != "" && $_GET['bit'] != "" && $_GET['value'] != "") {

include ("Mirrorbow.class.php");
$mb_device = new Mirrorbow();
$mb_device->mirrorbow_device = array("livingroom" => "192.168.1.76");

#!!entire port must be output
$mb_device->setPortDirection("livingroom",1,0);

#get port
$binary_port = $mb_device->getPortValueToBin("livingroom", $_GET["port"]);

#set bit 6 of port 1 to 1
$mb_device->setBitValue("livingroom", $binary_port, $_GET['bit'], $_GET['value']);

} else {
    echo "no parameters supplied<br/>";
    echo "example: http://localhost/portapi.php?port=1&bit=7&value=1";
}